package com.icen.utils.activities;

import com.icen.utils.comm.ToastUtils;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;

public class AppBaseActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

	}

	@Override
	protected void onResume() {
		super.onResume();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			this.appExit();
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

	private long clickTime = 0;

	private void appExit() {
		if (System.currentTimeMillis() - clickTime > 2000) {
			ToastUtils.show(this, "再按一次返回键退出程序");
			clickTime = System.currentTimeMillis();
		} else {
			this.finish();
			System.exit(0);
		}
	}
}
